#!/bin/sh

TARGET_DIR=/www/RuoYi-Vue/ruoyi-admin/target
DES_JAR_NAME=ruoyi-admin.jar
WORK_PATH=/www/RuoYi-Vue
LOG_NAME=$WORK_PATH/ruoyi-admin.log

\cp $TARGET_DIR/$DES_JAR_NAME $WORK_PATH

cd $WORK_PATH
JAVA_OPTS='-Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps  -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC'

PIDS=$(ps -ef|grep $DES_JAR_NAME | grep -v grep | awk '{print $2}')
for PID in $PIDS
 do kill -9 $PID
 echo " $PID has been killed"
done


echo 'App is Starting...'
nohup java $JAVA_OPTS -jar $DES_JAR_NAME >$LOG_NAME 2>&1 &
echo 'Start Success!'
